﻿using SnakeGame.Lesson1;
using SnakeGame.Lesson3;
using SnakeGame.Lesson4;

namespace SnakeGame.Lesson5
{
    internal class Map : IDarw
    {
        public Wall[] walls;

        public Map()
        {
            int width = Game.width;
            int height = Game.height;
            int wallCount = width + (height - 3) * 2;
            walls = new Wall[wallCount];
            int index = 0;

            // 上下边界
            for (int i = 0; i < width; i += 2)
            {
                walls[index++] = new Wall(i, 0);               // 上边界
                walls[index++] = new Wall(i, height - 2);      // 下边界
            }

            // 左右边界
            for (int i = 1; i < height - 2; i++)
            {
                walls[index++] = new Wall(0, i);               // 左边界
                walls[index++] = new Wall(width - 2, i);       // 右边界
            }
        }

        public void Draw()
        {
            for (int i = 0; i < walls.Length; i++)
            {
                walls[i].Draw();
            }
        }
    }
}